<meta charset="utf-8">
(#) Call is blocked in the Privacy Sandbox

!!! WARNING: Call is blocked in the Privacy Sandbox
   This is a warning.

Id
:   `PrivacySandboxBlockedCall`
Summary
:   Call is blocked in the Privacy Sandbox
Note
:   **This issue is disabled by default**; use `--enable PrivacySandboxBlockedCall`
Severity
:   Warning
Category
:   Correctness
Platform
:   Android
Vendor
:   Android Open Source Project
Feedback
:   https://issuetracker.google.com/issues/new?component=192708
Since
:   8.9.0-alpha03 (November 2024)
Affects
:   Kotlin and Java files
Editing
:   This check can *not* run live in the IDE editor
Implementation
:   [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/RestrictedEnvironmentBlockedCallDetector.kt)
Tests
:   [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/RestrictedEnvironmentBlockedCallDetectorTest.kt)

Many APIs are unavailable in the Privacy Sandbox, depending on the
`targetSdk`.

If your code is designed to run in the sandbox (and never outside the
sandbox) then you should remove the blocked calls to avoid exceptions at
runtime.

If your code is part of a library that can be executed both inside and
outside the sandbox, surround the code with `if
(!Process.isSdkSandbox()) { ... }` (or use your own field or method
annotated with `@ChecksRestrictedEnvironment`) to avoid executing
blocked calls when in the sandbox. Or, add the
`@RestrictedForEnvironment` annotation to the containing method if the
entire method should not be called when in the sandbox.

This check is disabled by default, and should only be enabled in modules
that may execute in the Privacy Sandbox.

(##) Suppressing

You can suppress false positives using one of the following mechanisms:

* Using a special `lint.xml` file in the source tree which turns off
  the check in that folder and any sub folder. A simple file might look
  like this:
  ```xml
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;lint&gt;
      &lt;issue id="PrivacySandboxBlockedCall" severity="ignore" /&gt;
  &lt;/lint&gt;
  ```
  Instead of `ignore` you can also change the severity here, for
  example from `error` to `warning`. You can find additional
  documentation on how to filter issues by path, regular expression and
  so on
  [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).

* In Gradle projects, using the DSL syntax to configure lint. For
  example, you can use something like
  ```gradle
  lintOptions {
      disable 'PrivacySandboxBlockedCall'
  }
  ```
  In Android projects this should be nested inside an `android { }`
  block.

* For manual invocations of `lint`, using the `--ignore` flag:
  ```
  $ lint --ignore PrivacySandboxBlockedCall ...`
  ```

* Last, but not least, using baselines, as discussed
  [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).

<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js" charset="utf-8"></script><script src="https://morgan3d.github.io/markdeep/latest/markdeep.min.js" charset="utf-8"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>